<extend name="Index/index" />
<block name="mycss">
     <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/my.css">
</block>

<block name="main">
    <div class="container">
        <div class="ww">
            <div class="fl">最近联系</div>
            <div class="fr"><button class="btn btn-primary " data-toggle="modal" data-target="#myModal">写私信</button>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog ">
      <div class="modal-content">
         <div class="modal-header bgq">
            <button type="button" class="close" 
               data-dismiss="modal" aria-hidden="true">
                  &times;
            </button>
            <h4 class="modal-title" id="myModalLabel">
               发送私信
            </h4>
         </div>
         <div class="modal-body">
            <form>
                <table>
                <tr style="margin-top:-25px;
    display: inline-block;">
                <th>发给:&nbsp;&nbsp;</th>
                <td><input type="text" class="yonghu"></td>
                <td><span class="pyh"></span></td>
                </tr>
                <tr style="margin-top:10px;
    display: inline-block;">
                <th>内容:&nbsp;&nbsp;</th>
                <td> <textarea name="" class="neirong" cols="60" rows="4"></textarea> </td>
                <td><span class="pnr"></span></td>
                </tr>
                </table>
            </form>
         </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" 
               data-dismiss="modal">取消
                    </button>
                    <button type="button" class="btn btn-primary sends fool">
                    发送
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
   </div>
        </div>
        </div>
</div>
<div>
        <for start='0' end="count($rows)">
        <div class="send">
        <div class="head fl"><img src="__PUBLIC__/imgs/<{$Think.session.home.image}>" width="45px" alt=""></div>
        <div class="za fr">
            <div class="fas">我发送给:<{$rows[$i][user][name]}>: <{$rows[$i][content]}></div>
            <div class="chak">
                <div class="time fl"><{$rows[$i][datetime]}></div>
                <div class="abq1 fr">
                    <!-- <span><a href="">查看对话</a></span> -->
<!--                     <span class="ccc">|</span>
                    <span><a href="" >回复</a>
                    </span> -->
                    <!-- <span class="ccc">|</span> -->
                    <span><a class="shanchu" bh="<{$rows[$i]['id']}>">删除</a></span>
                </div>
            </div>
        </div>
        </div>
        </for>


        <for start="0" end="count($fu)">
        <div class="send">
        <div class="head fl"><img src="__PUBLIC__/imgs/<{$fu[$i]['uimage']}>" width="45px" alt=""></div>
        <div class="za fr">
            <div class="fas"><{$fu[$i]['uname']}>:<{$fu[$i]['lcon']}></div>
            <div class="chak">
                <div class="time fl"><{$fu[$i]['ldat']}></div>
                <div class="abq1 fr">
                    <!-- <span><a href="">查看对话</a></span> -->
                    <!-- <span class="ccc">|</span> -->
                    <span><a href="" data-toggle="modal" 
   data-target="#myModaldef">回复</a>
                        <!-- 模态框（Modal） -->
                        <div class="modal fade" id="myModaldef" tabindex="-1" role="dialog" 
                            aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog ">
                                <div class="modal-content">
                            <div class="modal-header bgq">
                             <button type="button" class="close" 
                                data-dismiss="modal" aria-hidden="true">
                             &times;
                            </button>
            <h4 class="modal-title" id="myModalLabel">
               发送私信
            </h4>
         </div>
         <div class="modal-body">
            <form>
                <table>
                <tr style="margin-top:-120px;
    display: inline-block;">
                <th>发给:&nbsp;&nbsp;</th>
                <td><{$fu[$i]['uname']}></td>
                <td><span></span></td>
                </tr>
                <tr style="margin-top:30px;margin-left:-70px;
    display: inline-block;">
                <th>内容:&nbsp;&nbsp;</th>
                <td> <textarea name=""  cols="60" rows="4" class="rongnei"></textarea> </td>
                <td><span  class="pnr"></span></td>
                </tr>
                </table>
            </form>
         </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" 
               data-dismiss="modal">取消
                    </button>
                    <button type="button" class="btn btn-info fool songa" bj="<{$fu[$i]['uid']}>">
                    发送
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
        </div>
                    </span>


                    <span class="ccc">|</span>
                    <span><a  class="chus" nb="<{$fu[$i]['lid']}>">删除</a></span>
                </div>
            </div>
        </div>
        </div>
        </for>

        <div class="big">
            <div class="big1 fl"><img src="__PUBLIC__/imgs/zhihutuandui.jpg" alt="" width="45px"></div>
            <div class="big2 fr">
                <div class="shang">知乎团队 ：亲爱的 <{$_SESSION['home']['name']}>，
                    <p>见信好。</p>
                    <br>
                    <p>欢迎你来到知乎。知乎是中文互联网上最大的知识型讨论社区，在这里，你可以和千万用户分享你的知识、经验和见解。</p>
                    <br>
                    <p>为了让你更快捷地体验到知乎的乐趣，在此，我向你推荐知乎的手机 App：</p>
                    <br>
                    <p>通过知乎 App，你可以在任何你希望的时间进行阅读，关注你感兴趣的问题和用户，并且实时接收新回答提醒。</p>
                    <p>你还有机会体验到只有 App 中才有的功能——全新的语音直播，知乎 Live。</p>
                    <br>
                    <p>点击链接下载 App：<a href="">下载链接</a></p>
                    <br>
                    <p>祝你在这里发现更大的世界。</p>
                    <p>爱你的，</p>
                    <p>知乎团队╰(●'◡'●)╮</p>
                    <br>
                </div>
                <div class="xia">
                    <div class="date fl">7月19日 13:51</div>
                    <div class="del fr">
                        <span><a href="">查看对话</a></span>
                        <span class="ccc">|</span>
                        <span><a href="">删除</a></span>
                    </div>
                </div>
            </div>
        </div>
    </div>

</block>
<block name="myjs">

<script>
        $(".yonghu").blur(function(){
            if($(this).val() == ''){
                $('.pyh').text('请填写收信人');
            }else{
                $('.pyh').text('');
            }
}); 

                $(".neirong").blur(function(){
            if($(this).val() == ''){
                $('.pnr').text('请填写内容');
            }else{
                $('.pnr').text('');
            }
}); 

        $('.sends').click(function(){
            // $(this).parent().parent().parent().parent().hide();
            var yonghu = $('.yonghu').val();
            var neirong = $('.neirong').val();
            // console.log(yonghu);
            // console.log(neirong);
            $.ajax({
                type:'post',
                url:"<{:U('Inbox/send')}>",
                data:{'yonghu':yonghu,'neirong':neirong},
                success:function(data){
                    // console.log(data);
                    if (data == '0') {
                        alert('此用户不存在');
                    }else if(data == '1')
                    {
                        alert('已发送');
                        window.location.reload();
                    }
                }
            });
        })

        $('.chus').mouseover(function(){
            $(this).css('cursor','pointer');
        })
        $('.chus').click(function(){
            var id = $(this).attr('nb');

            $.ajax({
                type:'get',
                url:"<{:U('Inbox/shanchu')}>"+'?id='+id,
                success:function(data){
                    alert('已删除');
                    window.location.reload();
                }
            });
        })

        $('.shanchu').mouseover(function(){
            $(this).css('cursor','pointer');
        })
        $('.shanchu').click(function(){
            var id = $(this).attr('bh');

            $.ajax({
                type:'get',
                url:"<{:U('Inbox/shanchu')}>"+'?id='+id,
                success:function(data){
                    alert('已删除');
                    window.location.reload();
                }
                
            });
        })

        $('.songa').click(function(){
            var id=$(this).attr('bj');
            // var idd=$(this).attr('bh');
                    console.log($('.rongnei').val());
                    console.log(id);
                    console.log($('this'));
            // 
            $.ajax({
                type:'post',
                url:"<{:U('Inbox/index')}>",
                data:{'content':$('.rongnei').val(),'to_user_id':id},
                success:function(msg){
                    console.log(msg);

                    window.location.reload();
                }
            })
        })

        $('.fool').click(function(){
            $(this).attr('aria-hidden','true');
            $(this).attr('data-dismiss','modal');
            $(this).attr('class','close');
        })
</script>
</block>